/*
 * Copyright (c) 2007 jNetX.
 * http://www.jnetx.com
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * jNetX. You shall not disclose such Confidential Information and
 * shall use it only in accordance with the terms of the license
 * agreement you entered into with jNetX.
 *
 * $Id$
 */
package com.jnetx.javax.sip.header;

import javax.sip.address.Address;
import javax.sip.header.ReplyToHeader;

/**
 * The Reply-To header field contains a logical return URI that may be
 * different from the From header field.  For example, the URI MAY be used to
 * return missed calls or unestablished sessions. If the user wished to remain
 * anonymous, the header field SHOULD either be omitted from the request or
 * populated in such a way that does not reveal any private information.
 * <p>
 * For Example:<br>
 * <code>Reply-To: Bob sip:bob@biloxi.com</code>
 *
 * @see javax.sip.header.HeaderAddress
 * @see javax.sip.header.Parameters
 *
 * @author <a href="mailto:dparhonin@jnetx.ru">Dmitry Parhonin</a>
 * @version $Revision$
 */
public class ReplyToHeaderImpl extends ParametrizedHeaderBase implements ReplyToHeader {
    private static final ReplyToHeaderParser parser = new ReplyToHeaderParser();

    private Address address;

    public ReplyToHeaderImpl() {
        super(ReplyToHeader.NAME);
    }

    ReplyToHeaderImpl(byte[] data, int start, int end) {
        super(ReplyToHeader.NAME, data, start, end);
    }

    public Object clone() {
        final ReplyToHeaderImpl header = new ReplyToHeaderImpl();
        header.cloneBase(this);
        if (parsed) {
            header.cloneParameters(this);
            header.address = this.address;
        }
        return header;
    }

    protected HeaderParser getParser() {
        return parser;
    }

    protected String getValueAsString() {
        return address.toString();
    }

    /**
     * Sets the Address parameter of this Address.
     *
     * @param address the Address object that represents the new
     *                address of this Address.
     */
    public void setAddress(Address address) {
        parse();
        this.address = address;
        invalidateHeaderData();
    }

    /**
     * Gets the address parameter of this Address.
     *
     * @return the Address of this Address
     */
    public Address getAddress() {
        parse();
        return this.address;
    }
}
/*
 * $Log$
 */